//
//  AboutViewController.m
//  110
//
//  Created by 段报雪 on 16/4/12.
//  Copyright © 2016年 乔砥. All rights reserved.
//

#import "AboutViewController.h"
#import "AboutTableViewCell.h"
#import "StateViewController.h"
@interface AboutViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong)UIImageView *myImageView;

@property (nonatomic, strong)UITableView *myTableView;

@property (nonatomic,strong)UILabel *myLabel;

@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationItem.title = @"关于我们";
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"< 返回" style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemAction:)];
    
    _myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, KWIDTH, KHEIGHT / 4)];
    _myImageView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:_myImageView];
    
    _myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64 + KHEIGHT / 4, KWIDTH, KHEIGHT - 64) style:UITableViewStyleGrouped];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    [self.view addSubview:_myTableView];
    
    //  注册
    [_myTableView registerClass:[AboutTableViewCell class] forCellReuseIdentifier:@"cell"];
}

- (void)leftBarButtonItemAction:(UIBarButtonItem *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark ---- 返回分区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

#pragma mark ---- 返回行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 3;
    }
    return 1;
}

#pragma mark ---- Cell方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AboutTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    switch (indexPath.section)
    {
        case 0:
            if (indexPath.row == 0)
            {
                cell.textLabel.text = @"网站：";
                
                _myLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 10, 200, 30)];
                _myLabel.text = @"http://www.111.com.cn";
                _myLabel.textColor = [UIColor blueColor];
                [cell addSubview:_myLabel];
            }
            else if (indexPath.row == 1)
            {
                cell.textLabel.text = @"微博：";
            }
            else
            {
                cell.textLabel.text = @"微信";
                
                _myLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 10, 200, 30)];
                _myLabel.text = @" 公众号 : yihaoyaowang";
                _myLabel.textColor = [UIColor blueColor];
                [cell addSubview:_myLabel];
            }
            break;
        case 1:
        {
            cell.textLabel.text = @"免责声明";
        }
            break;
            
        default:
            break;
    }
    
    cell.textLabel.textColor = [UIColor grayColor];
    
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

#pragma mark ---- Cell点击方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.section)
    {
        case 0:
            if (indexPath.row == 0)
            {
               
                NSString *webStr = @"http://www.111.com.cn";
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:webStr]];
            }
            else if (indexPath.row == 1)
            {
                NSString *webStr = @"http://weibo.com/u/5076516542?refer_flag=1087030701_2975_2017_0&is_hot=1";
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:webStr]];
            }
            else
            {
                
            }
            break;
        case 1:
        {
            NSLog(@"免责声明");
            StateViewController *stateVC = [[StateViewController alloc] init];
            [self.navigationController pushViewController:stateVC animated:YES];
        }
            break;
            
        default:
            break;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
